package com.ydt.dockingclients.api;

import java.util.HashMap;
import java.util.Map;

/**
 * 运达通SDK API地址
 *
 * @author 李守良
 */
public enum YdtSdkApi {
    SDK_API("https://test.ydtny.cn","接口地址"),
    V1_AUTH_TOKEN("/open/api/customer/auth/token", "获取Token"),
    V1_MAINCARD_DETAIL("/open/api/customer/maincard/detail", "获取主卡余额"),
    V1_STATION_LIST("/open/api/customer/station/list", "获取油站列表"),
    V1_STATION_DETAIL("/open/api/customer/station/detail", "获取单个油站"),
    V1_ORDER_CREATE("/open/api/customer/order/create", "创建订单"),
    V1_ORDER_QRCODE("/open/api/customer/order/qrcode", "获取订单二维码"),
    V1_ORDER_DETAIL("/open/api/customer/order/detail", "订单查询"),
    V1_ORDER_REFUND("/open/api/customer/order/refund", "订单申请退款");

    private final String url;
    private final String info;

    YdtSdkApi(String url, String info) {
        this.url = url;
        this.info = info;
    }

    public String getUrl() {
        return SDK_API.url.concat(url);
    }

    public String getInfo() {
        return info;
    }

    public static Map<String, String> toMap() {
        Map<String, String> map = new HashMap<String, String>();
        for (YdtSdkApi type : YdtSdkApi.values()) {
            map.put(type.getUrl(), type.getInfo());
        }
        return map;
    }

    public static String getInfoByUrl(String url) {
        String result = null;
        Map<String, String> multiMap = YdtSdkApi.toMap();
        for (Map.Entry<String, String> stringObjectEntry : multiMap.entrySet()) {
            if (stringObjectEntry.getKey().equals(url)) {
                result = stringObjectEntry.getValue();
            }
        }
        return result;
    }
}

